package com.base.controller;

import com.base.po.tbk.TbkChoiceGoods;
import com.base.po.tbk.TbkGoodContent;
import com.base.service.LogsService;
import com.base.service.TbkGoodContentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;

/**
 * 修改好货专场信息服务端
 * 
 * @author f
 *
 */
@Controller
@RequestMapping("/admin")
public class update_GoodContent {

	@Autowired
	private LogsService logsService; // log日志
	@Autowired
	private TbkGoodContentService tbkGoodContentService; // 商品分类信息

	@RequestMapping("/updateGoodContent")
	public ModelAndView updateGoodContent(HttpServletRequest request, String id) throws Exception {
		ModelAndView modelAndView = new ModelAndView();

		TbkGoodContent tbkGoodContent = tbkGoodContentService.selectByPrimaryKey(id);

		request.setAttribute("tbkGoodContent", tbkGoodContent);
        modelAndView.setViewName("jsp/update_GoodContent");
		return modelAndView;
	}

	@RequestMapping(value = "/toUpdateGoodContent", method = RequestMethod.POST)
	public @ResponseBody int toUpdateGoodContent(HttpServletRequest request, TbkGoodContent tbkGoodContent) throws Exception {
		if (request.getSession().getAttribute("adminUserId") == null) return -1; // 未登录
		return tbkGoodContentService.updateByPrimaryKeySelective(tbkGoodContent); // 修改
	}
}
